Change in openvpn[master]: Windows: enforce 'block-local' with WFP filters
A message that is not in the archive (sent off-list or not yet received): gerrit.1704761332000.Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
to review the following change.
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 299 insertions(+), 213 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/489/1
CMakeLists.txt +2 -2
@@ -352,8 +352,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -533,6 +531,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +3 -0
@@ -352,6 +352,9 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to defend against the TunnelCrack attacks. :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +16 -10
@@ -1916,12 +1916,15 @@ c->c2.es);#if defined(_WIN32) -if (c->options.block_outside_dns) +/* Fortify 'redirect-gateway block-local' with firewall rules? */ +bool block_local =do_block_local (c->c1.route_list); + +if (c->options.block_outside_dns || block_local) { -dmsg (D_LOW ,"Blocking outside DNS" ); -if (!win_wfp_block_dns (c->c1.tuntap->adapter_index, c->options.msg_channel)) +BOOL dns_only = !block_local; +if (!win_wfp_block (c->c1.tuntap->adapter_index, c->options.msg_channel, dns_only)) { -msg (M_FATAL ,"Blocking DNS failed!" ); +msg (M_FATAL ,"WFP: blocking failed!" ); } }#endif
@@ -1965,12 +1968,15 @@ c->c2.es); }#if defined(_WIN32) -if (c->options.block_outside_dns) +/* Fortify 'redirect-gateway block-local' with firewall rules? */ +bool block_local =do_block_local (c->c1.route_list); + +if (c->options.block_outside_dns || block_local) { -dmsg (D_LOW ,"Blocking outside DNS" ); -if (!win_wfp_block_dns (c->c1.tuntap->adapter_index, c->options.msg_channel)) +BOOL dns_only = !block_local; +if (!win_wfp_block (c->c1.tuntap->adapter_index, c->options.msg_channel, dns_only)) { -msg (M_FATAL ,"Blocking DNS failed!" ); +msg (M_FATAL ,"WFP: blocking failed!" ); } }#endif
@@ -2093,7 +2099,7 @@ c->c2.es);#if defined(_WIN32) -if (c->options.block_outside_dns) +if (c->options.block_outside_dns ||do_block_local (c->c1.route_list)) {if (!win_wfp_uninit (adapter_index, c->options.msg_channel)) {
@@ -2132,7 +2138,7 @@ }#if defined(_WIN32) -if (c->options.block_outside_dns) +if (c->options.block_outside_dns ||do_block_local (c->c1.route_list)) {if (!win_wfp_uninit (adapter_index, c->options.msg_channel)) {
src/openvpn/route.c +38 -27
112 lines not on this page · raw message
src/openvpn/route.h +12 -4
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definatly returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool do_block_local (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
@@ -263,10 +275,6 @@void delete_route_ipv6 (const struct route_ipv6 *r,const struct tuntap *tt,unsigned int flags,const struct env_set *es,openvpn_net_ctx_t *ctx); -bool add_route (struct route_ipv4 *r,const struct tuntap *tt,unsigned int flags, -const struct route_gateway_info *rgi,const struct env_set *es, -openvpn_net_ctx_t *ctx); - void add_route_to_option_list(struct route_option_list *l, const char *network, const char *netmask,
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +88 -62
266 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: d12fk, flichtenheld, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 1:
(1 comment)
File src/openvpn/route.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/5b55e13a_2a09a8aa :
PS1, Line 78: static bool add_route(struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags,
this breaks compilation on a zillion of platforms that want to call add_route() from tun.c - please do not mix "cleanup of unrelated code" and "new features"
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Tue, 09 Jan 2024 07:03:33 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: d12fk, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 1: Code-Review-1
(9 comments)
File doc/man-sections/vpn-network-options.rst:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/fae460bf_083f3462 :
PS1, Line 357: Push this flag to defend against the TunnelCrack attacks.
Should explain a bit more what this protects against. A reference to TunnelCrack is fine but the documentation should be understandable without looking it up.
File src/openvpn/init.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/c60f4d43_2e7f9790 :
PS1, Line 1971: /* Fortify 'redirect-gateway block-local' with firewall rules? */
Since this hunk and the previous are completely identical I would move them to a separate function. 12 lines are definitely worth it IMHO.
File src/openvpn/route.h:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/703fcdb5_6ee704b9 :
PS1, Line 248: * is connected. This definatly returns false when not redirecting the gateway Typo "definatly"
File src/openvpn/route.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/39e95055_e284408d :
PS1, Line 612: size_t i;
no reason to leave that on its own line
File src/openvpn/wfp_block.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/d821e3e7_d0986f52 :
PS1, Line 167: * Block outgoing port 53 traffic except for "port 53" needs to be changed to reflect the new functionality
http://gerrit.openvpn.net/c/openvpn/+/489/comment/81797d0e_701d2e70 :
PS1, Line 197: FWPM_FILTER_CONDITION0 Condition[2];
Why remove the "= {0}" here?
http://gerrit.openvpn.net/c/openvpn/+/489/comment/d1a0883e_d9fb0c63 :
PS1, Line 294: /* Third filter. Block IPv4 to port 53 or all besided loopback. */
"besides"? Or maybe "except"?
http://gerrit.openvpn.net/c/openvpn/+/489/comment/919ec205_02180481 :
PS1, Line 303: /* Forth filter. Block IPv6 to port 53 or all besides loopback */
"Fourth"
File src/openvpn/win32.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/8c406c41_df81902d :
PS1, Line 1225: if (ret == false)
Simplify to "!win_get_exe_path(openvpnpath, _countof(openvpnpath))"
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Tue, 09 Jan 2024 09:15:29 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, plaisthos.
d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 1:
(10 comments)
File doc/man-sections/vpn-network-options.rst:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/616966e3_6506d21f :
PS1, Line 357: Push this flag to defend against the TunnelCrack attacks.
Quoted 1 line
Should explain a bit more what this protects against. […]
Agree not to explain TunnelCrack in the openvpn man page, but then references are not much of a thing in roff either. Could you elaborate what you have in mind? The technicalities are explained before the concluding sentence, so if you have a clue about TunnnelCrack things should be clear enough.
File src/openvpn/init.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/b47799d4_dca0b2c0 :
PS1, Line 1971: /* Fortify 'redirect-gateway block-local' with firewall rules? */
Quoted 1 line
Since this hunk and the previous are completely identical I would move them to a separate function. […]
I think there's even more duplicate code before. I'll take a look and submit a separate commit if it is not tightly related to wfp only.
File src/openvpn/route.h:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/0c835951_e7364760 :
PS1, Line 248: * is connected. This definatly returns false when not redirecting the gateway
Quoted 1 line
Typo "definatly"
Done
File src/openvpn/route.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/eb7787ef_be0c1c5c :
PS1, Line 78: static bool add_route(struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags,
Quoted 1 line
this breaks compilation on a zillion of platforms that want to call
add_route()from tun. […]
Right, failed to spot this. The build results speak for themselves. =/
http://gerrit.openvpn.net/c/openvpn/+/489/comment/0e347637_c3fa5a5a :
PS1, Line 612: size_t i;
Quoted 1 line
no reason to leave that on its own line
Done
File src/openvpn/wfp_block.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/97c5a316_ea67f28e :
PS1, Line 167: * Block outgoing port 53 traffic except for
Quoted 1 line
"port 53" needs to be changed to reflect the new functionality
Done
http://gerrit.openvpn.net/c/openvpn/+/489/comment/ff62cf3d_89d511ff :
PS1, Line 197: FWPM_FILTER_CONDITION0 Condition[2];
Quoted 1 line
Why remove the "= {0}" here?
because the filters are zeroed right below, and than copied into [0] and/or [1] below as needed, so there's no uninitialized memory.
http://gerrit.openvpn.net/c/openvpn/+/489/comment/662c3688_6dc87eea :
PS1, Line 294: /* Third filter. Block IPv4 to port 53 or all besided loopback. */
Quoted 1 line
"besides"? Or maybe "except"?
Done
http://gerrit.openvpn.net/c/openvpn/+/489/comment/af60e388_d7cb7c20 :
PS1, Line 303: /* Forth filter. Block IPv6 to port 53 or all besides loopback */
Quoted 1 line
"Fourth"
Done
File src/openvpn/win32.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/bdfe473f_2369c40d :
PS1, Line 1225: if (ret == false)
Quoted 1 line
Simplify to "!win_get_exe_path(openvpnpath,
_countof(openvpnpath))"
We need to set ret as return value anyway, so doing it before the if is more readable IMHO compared to cramming the function call between the parentheses.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 09 Jan 2024 13:16:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, d12fk, plaisthos.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 1:
(2 comments)
File doc/man-sections/vpn-network-options.rst:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/9ab5407d_5fbd4418 :
PS1, Line 357: Push this flag to defend against the TunnelCrack attacks.
Quoted 1 line
Agree not to explain TunnelCrack in the openvpn man page, but then references are not much of a thin […]
Most terminals handle links sensibly these days. Also we publish this as HTML documentation. We already have existing http links in the document. So adding a link would probably not be a bad idea. How about:
"Push this flag to protect against attacks where the attacker tries to tricks the client into accessing services through a public network instead of the VPN (See e.g. https://tunnelcrack.mathyvanhoef.com/)."
File src/openvpn/win32.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/70f36809_aae74546 :
PS1, Line 1225: if (ret == false)
Quoted 1 line
We need to set ret as return value anyway, so doing it before the if is more readable IMHO compared […]
Right, but you could just replace the "got out" with "return false" anyway.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Tue, 09 Jan 2024 13:42:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, d12fk, flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 317 insertions(+), 240 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/489/2
CMakeLists.txt +2 -2
@@ -352,8 +352,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -533,6 +531,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +36 -39
106 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool do_block_local (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +90 -64
273 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, flichtenheld, plaisthos.
d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 2:
(1 comment)
File src/openvpn/init.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/536482e0_0434a02b :
PS1, Line 1971: /* Fortify 'redirect-gateway block-local' with firewall rules? */
Quoted 1 line
I think there's even more duplicate code before. […]
Okay there's not much to gain with respect to breaking out run_up_down, as that one requires too much special handling between the up and down cases.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 09 Jan 2024 14:39:14 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
to look at the new patch set (#3).
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 333 insertions(+), 240 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/489/3
CMakeLists.txt +2 -2
@@ -352,8 +352,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -533,6 +531,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +52 -39
122 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool do_block_local (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +90 -64
273 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, flichtenheld, plaisthos.
d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 3:
(5 comments)
File doc/man-sections/vpn-network-options.rst:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/b1bfa846_8997b555 :
PS1, Line 357: Push this flag to defend against the TunnelCrack attacks.
Quoted 1 line
Most terminals handle links sensibly these days. Also we publish this as HTML documentation. […]
Done
File src/openvpn/init.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/2586766b_9e2183fd :
PS1, Line 1971: /* Fortify 'redirect-gateway block-local' with firewall rules? */
Quoted 1 line
Okay there's not much to gain with respect to breaking out
run_up_down, as that one requires too muc […]
Done
File src/openvpn/route.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/2b4628b0_c3b07ee0 :
PS1, Line 78: static bool add_route(struct route_ipv4 *r, const struct tuntap *tt, unsigned int flags,
Quoted 1 line
Right, failed to spot this. The build results speak for themselves. […]
Done
File src/openvpn/wfp_block.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/ed619643_4cbcafe1 :
PS1, Line 197: FWPM_FILTER_CONDITION0 Condition[2];
Quoted 1 line
because the filters are zeroed right below, and than copied into [0] and/or [1] below as needed, so […]
Done
File src/openvpn/win32.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/a0fa7528_684d91ad :
PS1, Line 1225: if (ret == false)
Quoted 1 line
Right, but you could just replace the "got out" with "return false" anyway.
Yes, but no. The function has a single point of return, let's keep it that way. There's not enough to gain by changing this.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 09 Jan 2024 14:53:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
to look at the new patch set (#4).
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 337 insertions(+), 243 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/489/4
CMakeLists.txt +2 -2
@@ -352,8 +352,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -533,6 +531,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool do_block_local (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +90 -64
273 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 4
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, d12fk, flichtenheld, plaisthos.
stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 4:
(5 comments)
File include/openvpn-msg.h:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/b79b7779_628d912d :
PS4, Line 27: #include <windef.h>
why those are needed here?
File src/openvpn/route.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/e376b80f_a07c08de :
PS4, Line 621: do_block_local(const struct route_list *rl)
since this function doesn't really do any blocking and only check options, maybe rename to "is_block_local_needed()" ?
File src/openvpn/wfp_block.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/98a45da8_a4f2c958 :
PS4, Line 310: /* Fifth filter. Permit IPv4 for the VPN interface.
Permit DNS or all IPv4 traffic for the VPN interface?
http://gerrit.openvpn.net/c/openvpn/+/489/comment/d9207c40_fa180f47 :
PS4, Line 327: /* Sixth filter. Permit IPv6 for the VPN interface.
Same as above - Permit DNS or all IPv6 traffic for the VPN interface?
File src/openvpn/win32.h:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/55c79df7_1e0f8209 :
PS4, Line 28: #include <iphlpapi.h>
why those changes?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 4
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 10 Jan 2024 10:16:58 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: cron2, d12fk, flichtenheld, plaisthos.
Hello flichtenheld, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
to look at the new patch set (#5).
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 337 insertions(+), 243 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/489/5
CMakeLists.txt +2 -2
@@ -352,8 +352,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -533,6 +531,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool block_local_needed (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +90 -64
273 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: cron2, flichtenheld, plaisthos, stipa.
d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 4:
(5 comments)
File include/openvpn-msg.h:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/8bc08e9f_7c28e168 :
PS4, Line 27: #include <windef.h>
Quoted 1 line
why those are needed here?
They define some types used in the header. Not that all wouldn't compile without them, but when looking at the single file (like clangd does) these undefinedness.
File src/openvpn/route.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/25c045e0_c6d575fc :
PS4, Line 621: do_block_local(const struct route_list *rl)
Quoted 1 line
since this function doesn't really do any blocking and only check options, maybe rename to "
is_block[…]
Done
File src/openvpn/wfp_block.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/50237516_00bec708 :
PS4, Line 310: /* Fifth filter. Permit IPv4 for the VPN interface.
Quoted 1 line
Permit DNS or all IPv4 traffic for the VPN interface?
Done
http://gerrit.openvpn.net/c/openvpn/+/489/comment/7e9bc610_f12f2c41 :
PS4, Line 327: /* Sixth filter. Permit IPv6 for the VPN interface.
Quoted 1 line
Same as above - Permit DNS or all IPv6 traffic for the VPN interface?
Done
File src/openvpn/win32.h:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/fff56b45_305383c8 :
PS4, Line 28: #include <iphlpapi.h>
Quoted 1 line
why those changes?
They define some types used in the header. Not that all wouldn't compile without them, but when looking at the single file (like clangd does) these undefinedness.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 4
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 10 Jan 2024 15:47:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: stipa <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, d12fk, plaisthos, stipa.
flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 5: Code-Review+1
(2 comments)
Patchset:
PS5:
Generally looks fine to me
File src/openvpn/win32.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/4f22baef_1cbaf8d1 :
PS1, Line 1225: if (ret == false)
Quoted 1 line
Yes, but no. The function has a single point of return, let's keep it that way. […]
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-CC: stipa <[email protected]...>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Fri, 12 Jan 2024 16:25:11 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: flichtenheld <[email protected]...>
Comment-In-Reply-To: d12fk <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, d12fk, plaisthos.
stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 5: Code-Review+2
(2 comments)
File include/openvpn-msg.h:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/d1fb891c_bb0bba56 :
PS4, Line 27: #include <windef.h>
Quoted 1 line
They define some types used in the header. […]
Acknowledged
File src/openvpn/win32.h:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/e3203291_cfd5bef9 :
PS4, Line 28: #include <iphlpapi.h>
Quoted 1 line
They define some types used in the header. […]
Acknowledged
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Jan 2024 08:56:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: d12fk <[email protected]...>
Comment-In-Reply-To: stipa <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, d12fk, plaisthos.
stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5:
Looks good to me. I have compiled it with MSVC and tested following scenarios (with server pushing block-local)
- access to LAN is blocked (got "general failure" when pinging local gateway)
- traffic to VPN gateway is blocked expect from VPN process (got "general failure" when pinging VPN gateway via its public IP)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 17 Jan 2024 09:05:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
PATCH v5 1/1 Windows: enforce 'block-local' with WFP filters
In reply to a message not in the archiveFrom: Heiko Hund <[email protected]...>
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/489
This mail reflects revision 5 of this Change. Acked-by according to Gerrit (reflected above):
Lev Stipakov <[email protected]...>
CMakeLists.txt +2 -2
@@ -352,8 +352,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -533,6 +531,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/block_dns.c deleted +0 -423
423 lines not on this page · raw message
src/openvpn/block_dns.h deleted +0 -69
69 lines not on this page · raw message
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool block_local_needed (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c new file +449 -0
449 lines not on this page · raw message
src/openvpn/wfp_block.h new file +73 -0
73 lines not on this page · raw message
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
Attention is currently required from: d12fk, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 5: Code-Review-1
(2 comments)
Patchset:
PS5:
Overall the patch does what it says, but it is not -Werror clean.
Please fix, rebase (copyright dates have changed for the files renamed and commit 989b22cb6e0 moved around "pipe_message_t" + changed indentation). Thanks.
File src/openvpn/init.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/a60e11c6_446166ef :
PS5, Line 2058: unsigned long adapter_index;
This is not -Werror clean. GH builds complain
```
init.c:2115:26: error: variable 'adapter_index' is uninitialized when used here [-Werror,-Wuninitialized]
68
del_wfp_block(c, adapter_index);
69
^~~~~~~~~~~~~
70
init.c:2047:32: note: initialize the variable 'adapter_index' to silence this warning
71
unsigned long adapter_index;
72
^
73
= 0
74
1 error generated.
```This is trivially adjusted (=0) but according to project rules I can't do that.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Sat, 18 May 2024 16:08:30 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: cron2, plaisthos.
d12fk has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 5:
(1 comment)
File src/openvpn/init.c:
http://gerrit.openvpn.net/c/openvpn/+/489/comment/ded84325_5a2a76b6 :
PS5, Line 2058: unsigned long adapter_index;
Quoted 1 line
This is not
-Werrorclean. GH builds complain […]
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 5
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Mon, 03 Jun 2024 23:57:42 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Gerrit-MessageType: comment
Attention is currently required from: cron2, flichtenheld, plaisthos, stipa.
Hello cron2, flichtenheld, plaisthos, stipa,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
to look at the new patch set (#6).
The following approvals got outdated and were removed:
Code-Review+1 by flichtenheld, Code-Review+2 by stipa, Code-Review-1 by cron2
The change is no longer submittable: Code-Review and checks~ChecksSubmitRule are unsatisfied now.
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 365 insertions(+), 243 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/489/6
CMakeLists.txt +2 -2
@@ -369,8 +369,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -550,6 +548,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool block_local_needed (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +118 -64
301 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 6
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset
Attention is currently required from: d12fk, flichtenheld, plaisthos, stipa.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 6: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 6
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 05 Jun 2024 12:38:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v6 1/1 Windows: enforce 'block-local' with WFP filters
In reply to a message not in the archiveFrom: Heiko Hund <[email protected]...>
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/489
This mail reflects revision 6 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
CMakeLists.txt +2 -2
@@ -369,8 +369,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -550,6 +548,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/block_dns.c deleted +0 -423
423 lines not on this page · raw message
src/openvpn/block_dns.h deleted +0 -69
69 lines not on this page · raw message
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool block_local_needed (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c new file +477 -0
477 lines not on this page · raw message
src/openvpn/wfp_block.h new file +73 -0
73 lines not on this page · raw message
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
[Openvpn-devel] [PATCH applied] Re: Windows: enforce 'block-local' with WFP filters
Lev has tested it and confirms that it works, I have stared long and hard at v5 of the patch, and the diffs v5->v6. The main difference v5->v6 is to make it error clean (add a "= 0") *and* that it also blocks DNS going out of the loopback interface - so if there's magic DNS proxy software using 127.0.0.1:53, the old "block-outside-dns" code would have not blocked it, but this new code *will*. Somewhat unrelated featurette, but same code path, and same intent "avoid VPN leaks of any kind, DNS or data".
This is really nice functionality to ward of all "TunnelCrack" or "TunnelVision" style attacks on Windows clients, by extending the existing "redirect-gateway block-local" config option to add WFP firewall filters to really *really* block everything not going into the tunnel.
I would have wished for two patches ("one for the renaming, one for the functional changes") but I already postponed this for too long...
In addition to Lev's tests I have compile-tested on GHA and a local MinGW build. No surprises there.
I intend to apply this to release/2.6 as well as master, but want to have more test coverage first. So I'll send mails around to solicit test coverage as soon as I have a git master snapshot installer to test.
Your patch has been applied to the master branch.
commit bf887c95e46c6892ac1f68be5559525f8d975530 (master)
Author: Heiko Hund Date: Wed Jun 5 14:38:56 2024 +0200
Windows: enforce 'block-local' with WFP filters
Signed-off-by: Heiko Hund <[email protected]...>
Acked-by: Lev Stipakov <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: d12fk, flichtenheld, plaisthos.
stipa has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Patch Set 6: Code-Review+1
(1 comment)
Patchset:
PS6:
Looks good to me. I did some testing and found out that:
1) "block-local" also blocks traffic to the remote except by openvpn proces - which is somewhat expected since we are supposed to block everything not going into VPN.
2) If there is a direct route to the remote, openvpn thinks that this is on local network, and thus disables block-local functionality. I don't think this is expected, but this part is outside of scope of this patch.
We could resolve (2) later.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 6
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 05 Jun 2024 14:48:54 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
cron2 has uploaded a new patch set (#7) to the change originally created by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
The following approvals got outdated and were removed:
Code-Review+1 by stipa, Code-Review+2 by cron2
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28717.html
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 365 insertions(+), 243 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/489/7
CMakeLists.txt +2 -2
@@ -369,8 +369,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -550,6 +548,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool block_local_needed (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +118 -64
301 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 7
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28717.html
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 365 insertions(+), 243 deletions(-)
CMakeLists.txt +2 -2
@@ -369,8 +369,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -550,6 +548,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool block_local_needed (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +118 -64
301 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 7
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged
Attention is currently required from: flichtenheld, plaisthos, stipa.
its_Giaan has uploaded a new patch set (#7) to the change originally created by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28717.html
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 365 insertions(+), 243 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/89/489/7
CMakeLists.txt +2 -2
@@ -369,8 +369,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -550,6 +548,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool block_local_needed (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +118 -64
301 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 7
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/489?usp=email )
Change subject: Windows: enforce 'block-local' with WFP filters
......................................................................
Windows: enforce 'block-local' with WFP filters
In an attempt to better defend against the TunnelCrack attacks, enforce that no traffic can pass to anything else than the VPN interface when the 'block-local' flags is given with either --redirect-gateway or --redirect-private.
Reuse much of the existing --block-outside-dns code, but make it more general, so that it can also block any traffic, not just port 53.
Uses the Windows Filtering Platform for enforcement in addition to the routes redirecting the networks into the tunnel.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg28717.html
---
M CMakeLists.txt
M doc/man-sections/vpn-network-options.rst
M include/openvpn-msg.h
M src/openvpn/Makefile.am
M src/openvpn/init.c
M src/openvpn/route.c
M src/openvpn/route.h
M src/openvpn/tun.c
R src/openvpn/wfp_block.c
R src/openvpn/wfp_block.h
M src/openvpn/win32.c
M src/openvpn/win32.h
M src/openvpnserv/CMakeLists.txt
M src/openvpnserv/Makefile.am
M src/openvpnserv/interactive.c
15 files changed, 365 insertions(+), 243 deletions(-)
CMakeLists.txt +2 -2
@@ -369,8 +369,6 @@ src/openvpn/base64.c src/openvpn/base64.h src/openvpn/basic.h - src/openvpn/block_dns.h - src/openvpn/block_dns.c src/openvpn/buffer.c src/openvpn/buffer.h src/openvpn/circ_list.h
@@ -550,6 +548,8 @@ src/openvpn/ssl_util.h src/openvpn/vlan.c src/openvpn/vlan.h + src/openvpn/wfp_block.c + src/openvpn/wfp_block.h src/openvpn/win32.c src/openvpn/win32-util.c src/openvpn/win32.h
doc/man-sections/vpn-network-options.rst +4 -0
@@ -352,6 +352,10 @@ Block access to local LAN when the tunnel is active, except for the LAN gateway itself. This is accomplished by routing the local LAN (except for the LAN gateway address) into the tunnel. + On Windows WFP filters are added in addition to the routes which + block access to resources not routed through the VPN adapter. + Push this flag to protect against TunnelCrack type of attacks + (see: https://tunnelcrack.mathyvanhoef.com/). :code:`ipv6` Redirect IPv6 routing into the tunnel. This works similar to
include/openvpn-msg.h +12 -3
@@ -24,6 +24,9 @@ #ifndef OPENVPN_MSG_H_ #define OPENVPN_MSG_H_ +#include <windef.h> +#include <ws2tcpip.h> + typedef enum { msg_acknowledgement, msg_add_address,
@@ -35,8 +38,8 @@ msg_add_nbt_cfg, msg_del_nbt_cfg, msg_flush_neighbors, - msg_add_block_dns, - msg_del_block_dns, + msg_add_wfp_block, + msg_del_wfp_block, msg_register_dns, msg_enable_dhcp, msg_register_ring_buffers,
@@ -61,6 +64,11 @@char name[256 ]; } interface_t; +typedef enum { + wfp_block_local =1 <<0 , + wfp_block_dns =1 <<1 +}wfp_block_flags_t ; + typedef struct { message_header_t header; short family;
@@ -120,8 +128,9 @@typedef struct {message_header_t header; +wfp_block_flags_t flags;interface_t iface; -}block_dns_message_t ; +}wfp_block_message_t ; typedef struct { message_header_t header;
src/openvpn/Makefile.am +1 -1
@@ -156,6 +156,6 @@ $(OPTIONAL_DL_LIBS) \ $(OPTIONAL_INOTIFY_LIBS) if WIN32 -openvpn_SOURCES += openvpn_win32_resources.rc block_dns.c block_dns.h ring_buffer.h +openvpn_SOURCES += openvpn_win32_resources.rc wfp_block.c wfp_block.h ring_buffer.h openvpn_LDADD += -lgdi32 -lws2_32 -lwininet -lcrypt32 -liphlpapi -lwinmm -lfwpuclnt -lrpcrt4 -lncrypt -lsetupapi -lbcrypt endif
src/openvpn/init.c +56 -42
137 lines not on this page · raw message
src/openvpn/route.c +33 -27
107 lines not on this page · raw message
src/openvpn/route.h +12 -0
@@ -243,6 +243,18 @@struct iroute_ipv6 *next; }; +/** +* Get the decision whether to block traffic to local networks while the VPN +* is connected. This definitely returns false when not redirecting the gateway +* or when the 'block-local' flag is not set. Also checks for other +* prerequisites to redirect local networks into the tunnel. +* +* @param rl const pointer to the struct route_list to base the decision on. +* +* @return boolean indicating whether local traffic should be blocked. +*/ +bool block_local_needed (const struct route_list *rl); +struct route_option_list *new_route_option_list (struct gc_arena *a);struct route_ipv6_option_list *new_route_ipv6_option_list (struct gc_arena *a);
src/openvpn/tun.c +1 -1
@@ -44,7 +44,7 @@#include "manage.h" #include "route.h" #include "win32.h" -#include "block_dns.h" +#include "wfp_block.h" #include "networking.h" #include "memdbg.h"
src/openvpn/wfp_block.c renamed from src/openvpn/block_dns.c +118 -64
301 lines not on this page · raw message
src/openvpn/wfp_block.h renamed from src/openvpn/block_dns.h +12 -8
@@ -23,20 +23,24 @@#ifdef _WIN32 -#ifndef OPENVPN_BLOCK_DNS_H -#define OPENVPN_BLOCK_DNS_H +#ifndef WFP_BLOCK_H +#define WFP_BLOCK_H + +#include <windef.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> /* Any value less than 5 should work fine. 3 is chosen without any real reason. */ -#define BLOCK_DNS_IFACE_METRIC 3 +#define WFP_BLOCK_IFACE_METRIC 3 -typedef void (*block_dns_msg_handler_t ) (DWORD err,const char *msg); +typedef void (*wfp_block_msg_handler_t ) (DWORD err,const char *msg);DWORD -delete_block_dns_filters (HANDLE engine); +delete_wfp_block_filters (HANDLE engine);DWORD -add_block_dns_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, -block_dns_msg_handler_t msg_handler_callback); +add_wfp_block_filters (HANDLE *engine,int iface_index,const WCHAR *exe_path, +wfp_block_msg_handler_t msg_handler_callback,BOOL dns_only);/** * Return interface metric value for the specified interface index.
@@ -65,5 +69,5 @@ set_interface_metric(const NET_IFINDEX index, const ADDRESS_FAMILY family, const ULONG metric); -#endif /* ifndef OPENVPN_BLOCK_DNS_H */ +#endif /* ifndef WFP_BLOCK_H */ #endif /* ifdef _WIN32 */
src/openvpn/win32.c +61 -46
174 lines not on this page · raw message
src/openvpn/win32.h +4 -2
@@ -25,8 +25,10 @@#ifndef OPENVPN_WIN32_H #define OPENVPN_WIN32_H -#include <winioctl.h> +#include <iphlpapi.h> +#include <ws2tcpip.h> +#include "syshead.h" #include "mtu.h" #include "openvpn-msg.h" #include "argv.h"
@@ -286,7 +288,7 @@/* call self in a subprocess */ void fork_to_self (const char *cmdline); -bool win_wfp_block_dns (const NET_IFINDEX index,const HANDLE msg_channel); +bool win_wfp_block (const NET_IFINDEX index,const HANDLE msg_channel,BOOL dns_only);bool win_wfp_uninit (const NET_IFINDEX index,const HANDLE msg_channel);
src/openvpnserv/CMakeLists.txt +1 -1
@@ -17,7 +17,7 @@ interactive.c service.c service.h validate.c validate.h - ../openvpn/block_dns.c ../openvpn/block_dns.h + ../openvpn/wfp_block.c ../openvpn/wfp_block.h openvpnserv_resources.rc ../openvpn/ring_buffer.h )
src/openvpnserv/Makefile.am +1 -1
@@ -33,6 +33,6 @@ interactive.c \ service.c service.h \ validate.c validate.h \ - $(top_srcdir)/src/openvpn/block_dns.c $(top_srcdir)/src/openvpn/block_dns.h \ + $(top_srcdir)/src/openvpn/wfp_block.c $(top_srcdir)/src/openvpn/wfp_block.h \ openvpnserv_resources.rc \ $(top_srcdir)/src/openvpn/ring_buffer.h
src/openvpnserv/interactive.c +47 -45
211 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/489?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic9bf797bfc7e2d471998a84cb0f071db3e4832ba
Gerrit-Change-Number: 489
Gerrit-PatchSet: 7
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-Reviewer: stipa <[email protected]...>
Gerrit-CC: cron2 <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged